{% extends "./layouts/_base.njk" %}
{% block title %}
  公告板 Dashboard
{% endblock %}
{% block content %}
  <div class="app-main">
    <div class="dashboard-item mb-3">
      <div class="row">
        <div class="col-sm-6 col-lg-3">
          <div class="card">
            <div class="card-body clearfix">
              <div class="pull-right">
                <p class="h6 m-t-0">ORDERS</p>
                <p class="h3 m-b-0">325.00</p>
              </div>
              <div class="pull-left">
                <span class="img-avatar img-avatar-48 bg-primary"><i class="fa fa-dollar fa-1-5x"></i></span></div>
            </div>
          </div>
        </div>

        <div class="col-sm-6 col-lg-3">
          <div class="card">
            <div class="card-body clearfix">
              <div class="pull-right">
                <p class="h6 m-t-0">USERS</p>
                <p class="h3 m-b-0">120,000</p>
              </div>
              <div class="pull-left"><span class="img-avatar img-avatar-48 bg-danger"><i class="fa fa-user fa-1-5x"></i></span>
              </div>
            </div>
          </div>
        </div>

        <div class="col-sm-6 col-lg-3">
          <div class="card">
            <div class="card-body clearfix">
              <div class="pull-right">
                <p class="h6 m-t-0">VISITORS</p>
                <p class="h3 m-b-0">2,105,000</p>
              </div>
              <div class="pull-left">
                <span class="img-avatar img-avatar-48 bg-success"><i class="fa fa-arrow-down fa-1-5x"></i></span></div>
            </div>
          </div>
        </div>

        <div class="col-sm-6 col-lg-3">
          <div class="card">
            <div class="card-body clearfix">
              <div class="pull-right">
                <p class="h6 m-t-0">ALERTS</p>
                <p class="h3 m-b-0">453 条</p>
              </div>
              <div class="pull-left">
                <span class="img-avatar img-avatar-48 bg-purple"><i class="fa fa-comment-o fa-1-5x"></i></span></div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!--/count-->

    <div class="dashboard-item chart-item row mb-3">
      <div class="col-lg-6">
        <div class="card">
          <div class="card-header">
            <h4>每周用户</h4>
          </div>
          <div class="card-body">
            <div id="js-chartjs-pie"></div>
          </div>
        </div>
      </div>

      <div class="col-lg-6">
        <div class="card">
          <div class="card-header">
            <h4>交易记录</h4>
          </div>
          <div class="card-body">
            <div id="js-chartjs-lines"></div>
          </div>
        </div>
      </div>
    </div>
    <!--/charts-->

    <div class="dashboard-item row">

      <div class="col-lg-12">
        <div class="card">
          <div class="card-header">
            <h4>订单信息</h4>
          </div>
          <div class="card-body">
            <div class="table-responsive">
              <table class="table table-hover">
                <thead>
                  <tr>
                    <th>ID</th>
                    <th>订单名称</th>
                    <th>开始日期</th>
                    <th>截止日期</th>
                    <th>状态</th>
                    <th>进度</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <td>1</td>
                    <td>设计新主题</td>
                    <td>10/02/2020</td>
                    <td>12/05/2020</td>
                    <td><span class="label label-warning">待定</span></td>
                    <td>
                      <div class="progress progress-striped progress-sm">
                        <div class="progress-bar progress-bar-warning" style="width: 45%;"></div>
                      </div>
                    </td>
                  </tr>
                  <tr>
                    <td>2</td>
                    <td>网站重新设计</td>
                    <td>01/03/2020</td>
                    <td>12/04/2020</td>
                    <td><span class="label label-success">进行中</span></td>
                    <td>
                      <div class="progress progress-striped progress-sm">
                        <div class="progress-bar progress-bar-success" style="width: 30%;"></div>
                      </div>
                    </td>
                  </tr>
                  <tr>
                    <td>3</td>
                    <td>模型设计</td>
                    <td>10/10/2020</td>
                    <td>12/11/2020</td>
                    <td><span class="label label-warning">待定</span></td>
                    <td>
                      <div class="progress progress-striped progress-sm">
                        <div class="progress-bar progress-bar-warning" style="width: 25%;"></div>
                      </div>
                    </td>
                  </tr>
                  <tr>
                    <td>4</td>
                    <td>后台管理系统模板设计</td>
                    <td>25/01/2020</td>
                    <td>09/05/2020</td>
                    <td><span class="label label-success">进行中</span></td>
                    <td>
                      <div class="progress progress-striped progress-sm">
                        <div class="progress-bar progress-bar-success" style="width: 55%;"></div>
                      </div>
                    </td>
                  </tr>
                  <tr>
                    <td>5</td>
                    <td>前端设计</td>
                    <td>10/10/2020</td>
                    <td>12/12/2020</td>
                    <td><span class="label label-danger">未开始</span></td>
                    <td>
                      <div class="progress progress-striped progress-sm">
                        <div class="progress-bar progress-bar-danger" style="width: 0%;"></div>
                      </div>
                    </td>
                  </tr>
                  <tr>
                    <td>6</td>
                    <td>桌面软件测试</td>
                    <td>10/01/2020</td>
                    <td>29/03/2020</td>
                    <td><span class="label label-success">进行中</span></td>
                    <td>
                      <div class="progress progress-striped progress-sm">
                        <div class="progress-bar progress-bar-success" style="width: 75%;"></div>
                      </div>
                    </td>
                  </tr>
                  <tr>
                    <td>7</td>
                    <td>APP改版开发</td>
                    <td>25/02/2020</td>
                    <td>12/05/2020</td>
                    <td><span class="label label-danger">暂停</span></td>
                    <td>
                      <div class="progress progress-striped progress-sm">
                        <div class="progress-bar progress-bar-danger" style="width: 15%;"></div>
                      </div>
                    </td>
                  </tr>
                  <tr>
                    <td>8</td>
                    <td>Logo设计</td>
                    <td>10/02/2020</td>
                    <td>01/03/2020</td>
                    <td><span class="label label-warning">完成</span></td>
                    <td>
                      <div class="progress progress-striped progress-sm">
                        <div class="progress-bar progress-bar-success" style="width: 100%;"></div>
                      </div>
                    </td>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>

    </div>

  </div>
  <!--/body-->
{% endblock %}
{% block js_footer %}
  <script src="/js/libs/g2/g2.min.js"></script>
  <script>
      (function () {
          // page
          var Page = {
              init: function () {
                  this.initLine()
                  this.initPie()
              },
              initLine: function () {
                  var self = this

                  App.http({
                      // url: '/examples/data/fireworks-sales.json',
                      url: '/examples/data/fireworks-sales.json',
                      success: function (data) {
                          self.renderLine(data)
                      }
                  })
              },
              renderLine: function (data) {
                  const chart = new G2.Chart({
                      container: 'js-chartjs-lines',
                      autoFit: true,
                      height: 250
                  })
                  chart.data(data)
                  chart.line().position('Date*scales')
                  chart.render()
              },
              initPie: function () {
                  const data = [
                      { item: '事例一', count: 40, percent: 0.4 },
                      { item: '事例二', count: 21, percent: 0.21 },
                      { item: '事例三', count: 17, percent: 0.17 },
                      { item: '事例四', count: 13, percent: 0.13 },
                      { item: '事例五', count: 9, percent: 0.09 }
                  ]

                  const chart = new G2.Chart({
                      container: 'js-chartjs-pie',
                      autoFit: true,
                      height: 250
                  })

                  chart.coordinate('theta', {
                      radius: 0.75
                  })

                  chart.data(data)

                  chart
                      .interval()
                      .position('percent')
                      .color('item')
                      .label('percent', {
                          content: (data) => {
                              return `${data.item}: ${data.percent * 100}%`
                          }
                      })
                      .adjust('stack')

                  chart.render()
              }
          }

          // ready
          $(function () {
              Page.init()
          })
      }())
  </script>
{% endblock %}